%{
#include <stdio.h>
#include <string.h>
#include "bruch.h"
#include <stdlib.h>



void yyerror(const char *str)
{
        fprintf(stderr,"error: %s\n",str);
}

int yywrap()
{
        return 1;
}

go()
{
        yyparse();
}

%}

%union {
        int intval;
        char* string;
        Ratio rtio;
        
}


%token<rtio> RATIO DIV MULT ADD MINUS PLUS END EXIT
%type<rtio> primary
%type<rtio> mul_expr
%type<rtio> add_expr


%%
line:	
		| line add_expr END {print_bruch($2);} 
		;
add_expr: mul_expr {$$=$1;}
		| add_expr PLUS mul_expr {$$=plus($1,$3);}
		| add_expr MINUS mul_expr {$$=minus($1,$3);}
		;
mul_expr: primary {$$=$1;}
		| mul_expr MULT primary {$$=multi($1,$3);}
		| mul_expr DIV primary {$$=divi($1,$3);}		
        ;
primary: RATIO {$$=$1;}
		;

%%





















